import java.util.*;

public class demo4 {
    public static void main(String[] args) {
        Map<String,Integer> temp=new HashMap<>();
        temp.put("john",35);
        temp.put("bob",40);
        temp.put("Mike",50);
        temp.put("tom",600);
        temp.put("jerry",50);
        func(temp);
    }

    public static List<String> func(Map<String,Integer> temp){
        Queue<Map.Entry<String,Integer>> queue=new PriorityQueue<>(Comparator.comparingInt(Map.Entry::getValue));

        for(Map.Entry<String,Integer> x: temp.entrySet()){
            queue.add(x);
            if(queue.size()>3) queue.poll();
        }

        List<String> ret=new ArrayList<>();
        for(Map.Entry<String,Integer> x:queue){
            ret.add(x.getKey());
        }

        return ret;
    }
}
